home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / basic / qcopy.com / QCOPY2.BAS < prev   
Encoding:
BASIC Source File  |  1993-05-30  |  5.5 KB  |  177 lines

  1. '============================================================================
  2.   'I made this program to show you how to get a little bit of information
  3.   'that is sometimes needed when manipulating directory files and retriev
  4.   'ing dos information, I'm hopeful that this program will be of some aid
  5.   'for you.
  6.  
  7.   'QCOPY can be named any name you wish.
  8.  
  9.   'SYNTAX:  QCOPY [dir/specs]filename.ext  [dir/specs]filename.ext
  10.  
  11.   'NOTE: if an error occurs with QCOPY no message or error number is
  12.   '      returned or printed on screen, QCOPY just terminates.
  13.  
  14.   'For a personal copy program, check out COPYPRO in this forum, QCOPY
  15.   'is Free.
  16.   
  17.   'QCOPY 1.0,  S. Roepenack 1993
  18.   'for other programs, search with ID# 70373,516
  19.  
  20. '============================================================================
  21.   'Shell out to dos and make a file that its contents are of the current
  22.   'directory, the *.* could be *.BAS for only Bas Files, you could also
  23.   'use a path c:\*.*. the file name can be any name.
  24.  
  25.  '$DYNAMIC
  26.  
  27.   CLS : SCREEN 0
  28.   SHELL "DIR *.* > QDIR.FIL"
  29.  
  30. '============================================================================
  31.   'Count the number of Entrys needed to read into the DirArray$(), LineCount
  32.   'will give you the right number of dimensions needed for the array.
  33.  
  34.   OPEN "QDIR.FIL" FOR INPUT AS #1
  35.  
  36.   DO UNTIL EOF(1)
  37.     LINE INPUT #1, junk$
  38.     IF INSTR(FileLine$, "<DIR>") = 0 THEN
  39.       LineCount = LineCount + 1
  40.     END IF
  41.   LOOP
  42.  
  43.   CLOSE #1
  44.  
  45. '============================================================================
  46.   'Dimension the array with LineCount
  47.  
  48.   DIM DirArray$(LineCount)
  49.  
  50. '============================================================================
  51.   'Now open the file again and read it line by line into the DirArray()
  52.   'excluding any "<DIR>" found in QDIR.FIL, after reading it, close it
  53.   'and delete it from the current directory.
  54.  
  55.   OPEN "QDIR.FIL" FOR INPUT AS #1
  56.  
  57.   DO UNTIL EOF(1)
  58.        
  59.     LINE INPUT #1, FileLine$
  60.        
  61.     IF INSTR(FileLine$, "<DIR>") = 0 THEN
  62.       DirEntry = DirEntry + 1
  63.       DirArray$(DirEntry) = LTRIM$(FileLine$)
  64.     END IF
  65.  
  66.   LOOP
  67.  
  68.   CLOSE #1: KILL "QDIR.FIL"
  69.  
  70. '============================================================================
  71.   'Setting the variables Directory, Volume Label and so forth are determend
  72.   'by what line there on, DirEntry contains the highest count, inspecting
  73.   'the dir command directly from dos will give a better idea on how
  74.   'LineCount was used.
  75.  
  76.   LOCATE 2, 1: PRINT "( QuickSave with QCOPY and directory file manipulating )";
  77.   LOCATE 3, 1: PRINT STRING$(80, "-");
  78.  
  79.   Directory = 4
  80.   VolumeLabel = 2
  81.   SerialNumber = 3
  82.   DirFiles = DirEntry - 1
  83.   BytesFree = DirEntry
  84.     
  85.   LOCATE 5, 1: PRINT SPC(29); "DIRECTORY  INFORMATION"
  86.  
  87.   LOCATE 7, 5: PRINT "    Directory: " + DirArray$(Directory);
  88.   LOCATE 8, 5: PRINT " Volume Label: " + DirArray$(VolumeLabel);
  89.   LOCATE 9, 5: PRINT "Serial Number: " + DirArray$(SerialNumber);
  90.   LOCATE 10, 5: PRINT "        Files: " + DirArray$(DirFiles);
  91.   LOCATE 11, 5: PRINT "   Bytes Free: " + DirArray$(BytesFree);
  92.     
  93.   LOCATE 13, 1: PRINT STRING$(80, "-");
  94.   LOCATE 15, 1: PRINT SPC(27); "DIRECTORY FILE INFORMATION"
  95.  
  96.   LOCATE 17, 9: PRINT "     File: ";
  97.   LOCATE 18, 9: PRINT "File Size: ";
  98.   LOCATE 19, 9: PRINT "File Date: ";
  99.   LOCATE 20, 9: PRINT "File Time: ";
  100.  
  101.   LOCATE 22, 9: PRINT "Selected: ";
  102.   LOCATE 23, 10: PRINT "Save AS: ";
  103.  
  104.   LOCATE 19, 45: PRINT "Up, Down Arrow: File Selection";
  105.   LOCATE 18, 45: PRINT "     Enter Key: Except Selection";
  106.   LOCATE 20, 45: PRINT "    Escape Key: Quit Program";
  107.  
  108. '============================================================================
  109.   'Min is set to the least number and Max is set to the highest directory
  110.   'file in the array, the array index increases or decreases depending on
  111.   'what arrow key is pressed. DirArray is broken down into its components
  112.   'by using left$, right$ and mid$, to inspect this directly put a rem in
  113.   'front of FLeft$, FRight$, File$ and add this in place of them,
  114.   'File$ = DirArray$(ArrayIndex), the whole array will contain the line
  115.   'it read from QDIR.FIL.
  116.  
  117.   Min = 5
  118.   Max = (DirEntry - 2)
  119.   ArrayIndex = Min
  120.  
  121.   UP$ = CHR$(0) + CHR$(72)
  122.   DOWN$ = CHR$(0) + CHR$(80)
  123.   ESCAPE$ = CHR$(27)
  124.   ENTER$ = CHR$(13)
  125.  
  126.   DO
  127.      
  128.     DO
  129.       key$ = INKEY$
  130.     LOOP WHILE key$ = ""
  131.       
  132.     IF key$ = ENTER$ THEN EXIT DO
  133.     IF key$ = ESCAPE$ THEN END'Program
  134.    
  135.     IF (key$ = UP$ AND (ArrayIndex > Min)) THEN
  136.       ArrayIndex = ArrayIndex - 1
  137.     ELSEIF (key$ = DOWN$ AND (ArrayIndex < Max)) THEN
  138.       ArrayIndex = ArrayIndex + 1
  139.     END IF
  140.    
  141.     IF (ArrayIndex > Min) AND (ArrayIndex < Max) THEN
  142.          
  143.          FLeft$ = RTRIM$(LEFT$(DirArray$(ArrayIndex), 8))
  144.         FRight$ = RTRIM$(MID$(DirArray$(ArrayIndex), 10, 3))
  145.          
  146.           File$ = FLeft$ + "." + FRight$
  147.       FileSize$ = LTRIM$(MID$(DirArray$(ArrayIndex), 13, 10))
  148.       FileDate$ = MID$(DirArray$(ArrayIndex), 24, 8)
  149.       FileTime$ = MID$(DirArray$(ArrayIndex), 34, 6)
  150.  
  151.       LOCATE 17, 21: PRINT SPACE$(12);
  152.      
  153.       LOCATE 17, 21: PRINT File$;
  154.       LOCATE 18, 21: PRINT FileSize$;
  155.       LOCATE 19, 21: PRINT FileDate$;
  156.       LOCATE 20, 21: PRINT FileTime$;
  157.  
  158.     ELSE
  159.  
  160.       SOUND 67, .5
  161.  
  162.     END IF
  163.      
  164.   LOOP
  165.  
  166.   PRINT ""
  167.   LOCATE 22, 9: PRINT "Selected: " + File$
  168.   LOCATE 23, 10: PRINT "Save AS: ";
  169.   LINE INPUT SaveASFileName$
  170.  
  171.    'This will create another copy of File$ AS SaveASFileName$
  172.  
  173.  'SHELL "QCOPY " + File$ + " " + SaveASFileName$
  174.  
  175.   END
  176.  
  177.